/**
* Copyright @ 2023 iAuto (Shanghai) Co., Ltd.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are NOT permitted except as agreed by
* iAuto (Shanghai) Co., Ltd.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/


import {Descriptions, Image} from 'antd';
import IAutoDetail from '@/components/soa/IAutoDetail';
import React from 'react';
import style from './releaseDetail.less';

import { useRequest } from 'ahooks';
import { releaseHistoryDetail } from '@/services/soa/sceneOfficial';
import {getDateMinute, getDateTime} from "@/utils/soa/utils";

const Index = ({ location }: any) => {
  const { query } = location;

  const { data, loading } = useRequest(releaseHistoryDetail, {
    defaultParams: [query?.id],
  });

  return (
    <IAutoDetail className={style.main} title={'发布历史详情'} loading={loading}>
      <Descriptions column={1}  contentStyle={{whiteSpace: 'normal'}}>
        <Descriptions.Item label={'版本号'}>{data?.data?.version}</Descriptions.Item>
        <Descriptions.Item label={'场景名'}>{data?.data?.name}</Descriptions.Item>
        <Descriptions.Item label={'场景简介'} className={style.descriptionScene}>{data?.data?.description}</Descriptions.Item>
        <Descriptions.Item label={'品牌'}>
          {data?.data?.brandName}
        </Descriptions.Item>
        <Descriptions.Item label={'车系'}>
          {data?.data?.seriesName}
        </Descriptions.Item>
        <Descriptions.Item label={'车型'}>
          {data?.data?.modelName}
        </Descriptions.Item>
        <Descriptions.Item label={'场景分类'}>{data?.data?.categoryName}</Descriptions.Item>
        <Descriptions.Item label={'是否官方场景'}>{data?.data?.officialScene==0?"否":"是"}</Descriptions.Item>
        <Descriptions.Item label={'手机端可执行'}>{data?.data?.executedOnPhone==0?"否":"是"}</Descriptions.Item>
        <Descriptions.Item label={'场景图标'}>
          <Image src={data?.data?.iconUrl} preview={false} className={style.icon}/>
        </Descriptions.Item>
        <Descriptions.Item label={'场景背景'}>
          <Image src={data?.data?.backgroundPicUrl} preview={false} className={style.background}/>
        </Descriptions.Item>
        <Descriptions.Item label={'申请发布时间'}>{getDateTime(data?.data?.applyTime)}</Descriptions.Item>
        <Descriptions.Item label={'发布类型'}>{data?.data?.releaseType==0?"定时发布":"立即发布"}</Descriptions.Item>
        {data?.data?.releaseType==0 && (
          <Descriptions.Item label={'期望发布时间'} >{getDateMinute(data?.data?.cronReleaseTime)}</Descriptions.Item>
        )}

      </Descriptions>
    </IAutoDetail>
  );
};
export default Index;
